<#assign base=request.contextPath />
<!DOCTYPE html>
<html lang="en">
<head>
	<#include "/commons/headImport.ftl">
</head>
<body>
	<div class="main-container" id="main-container">
		<input type="hidden" value="${base}" id="context_hidden_id"/>
		<script type="text/javascript">
			try{ace.settings.check('main-container' , 'fixed')}catch(e){}
		</script>

		<div class="main-container-inner">
			<div class="main-content">
				<div class="page-content">
					<form class="form-horizontal" name="formName" method="post">
					<input type="hidden" value="${materielDetailDO.materielId!0}" id="materielId"/>
					<input type="hidden" value="${materielDetailDO.id!0}" id="detailId"/>
					<input type="hidden" value="${(materielDetailDO.materielDO.suppilerId)!0}" id="suppilerId"/>
					<input type="hidden" value="${((materielDetailDO.unitPrice/100.0)?string('0.00'))!0}" id="unitPrice"/>
					<div class="row">
						<div class="col-xs-12">
							<div class="space-4"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">名称:</label>
								<div class="col-sm-2">
									<div class="help-block col-xs-12 col-sm-reset inline">
									${(materielDetailDO.materielDO.name)!'--'}
									</div>
								</div>
								<label class="col-sm-2 control-label no-padding-right">规格型号:</label>
								<div class="col-sm-3">
									<div class="help-block col-xs-12 col-sm-reset inline">
									${(materielDetailDO.materielDO.spec)!'--'}
									</div>
								</div>
							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">总库存:</label>
								<div class="col-sm-2">
									<div class="help-block col-xs-12 col-sm-reset inline">${(materielDetailDO.materielDO.quantity)!'暂无'}</div>
								</div>
								<label class="col-sm-2 control-label no-padding-right">当前价格库存:</label>
								<div class="col-sm-3">
									<div class="help-block col-xs-12 col-sm-reset inline">${materielDetailDO.quantity!'暂无'}</div>
								</div>
							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">单价:</label>
								<div class="col-sm-3">
									<div class="help-block col-xs-12 col-sm-reset inline">
									${((materielDetailDO.unitPrice/100.0)?string.currency)!0}
									</div>
								</div>
							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">调整库存:</label>
								<div class="col-sm-2">
									<input type="text" value="0" id="quantity" AUTOCOMPLETE='off' class='col-sm-12 input-mini'/>
								</div>
								<div class="help-block col-xs-12 col-sm-reset inline">负数减少库存</div>
							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">备注:</label>
								<div class="col-sm-4">
									<textarea id="remark" class="col-xs-10 col-sm-12">${materielDetailDO.remark!''}</textarea>
								</div>
								<div class="help-block col-xs-12 col-sm-reset inline"></div>
							</div>
							<div class="space-4"></div>

							<div class="clearfix">
								<label class="col-sm-3 control-label no-padding-right"></label>
								<div class="col-md-offset-3 col-md-9">
									<a class="btn btn-xs btn-info" id="materiel_update_id"
										url="${base}/materielDetail/editQuantity">
										<i class="icon-save bigger-110"></i>保存
									</a>
									<button class="btn btn-xs" type="reset" id="return_id">
										<i class="icon-reply bigger-110"></i>关闭
									</button>
								</div>
							</div>
						</div><!-- /.col -->
					</div><!-- /.row -->
					</form>
				</div><!-- /.page-content -->
			</div><!-- /.main-content -->
		</div><!-- /.main-container-inner -->
	</div><!-- /.main-container -->
	
<#include "/commons/footJs.ftl">
<script src="${base}/static/layer/layer.js"></script>
<script src="${base}/static/assets/js/fuelux/fuelux.spinner.min.js"></script>
<script src="${base}/static/assets/js/jquery.inputlimiter.1.3.1.min.js"></script>
<script>
	jQuery(function($) {
		var index = parent.layer.getFrameIndex(window.name);

		$('#quantity').ace_spinner({
	   		value:$('#quantity').val(),min:-99999,max:99999,step:10, btn_up_class:'btn-info' , btn_down_class:'btn-info'
	   	})
		
		$("#return_id").click(function(){
			parent.layer.close(index);
		});

		$("#materiel_update_id").click(function(){
	   		var url=$(this).attr("url");
	       	var detailId = $("#detailId").val();
	       	var materielId = $("#materielId").val();
	       	var pageUnitPrice = $("#unitPrice").val();
	       	var quantity = $("#quantity").val();
	       	var remark = $("#remark").val();
	       	
	       	if(quantity==''||quantity==0){
	       		layer.msg("库存没有任何调整！");
	       		return false;
	       	}
	       	
	       	layer.load(2);
			$.ajax({
				type:"POST",
				url:url,
				dataType:"json",
				data:{
					"id":detailId,
					"materielId":materielId,
					"pageUnitPrice":pageUnitPrice,
					"quantity":quantity,
					"remark":remark
					},
			  	success:function(data){
				     if(data.success){
				     	layer.closeAll('loading');
				     	parent.layer.close(index);
				     	window.parent.location.reload(); //刷新父页面
				     }else{
				     	var json = JSON.stringify(data.msg);
				     	layer.msg(json);
				     	layer.closeAll('loading');
				     }
				  },
				  error:function(msg){
			     	var json = JSON.stringify(msg);
			     	layer.msg(json);
			     	layer.closeAll('loading');				 
				 }
			});
   		});
	});
</script>
</body>
</html>
